Ext.require('AM.component.menu.MenuItemFactory')

// Generic for right click menu

// 所有的菜单都是单例的 for 内存 效率
Ext.define('AM.component.menu.MenuFactory', {

    singleton:true,

    _textMenu:null,
    _imageMenu:null,
    _audioMenu:null,
    _videoMenu:null,
    _tableMenu:null,
    _pageMenu:null,
    _shapeMenu:null,


    textMenu:function () {
        if (this._textMenu == null) {
            var factory = AM.component.menu.MenuItemFactory;
            this._textMenu = Ext.create('Ext.menu.Menu', {
                items:[
                    factory.rotate(),
                    factory.scale(),
                    factory.opacity(),
                    factory.backgroundColor(),
                    factory.backgroundImage(),
                    factory.scaleBorder(),
                    factory.width(),
                    factory.height(),
                    factory.zIndex(),
                    factory.delete()
                ]
            })
        }

        return this._textMenu;
    },


    imageMenu:function () {
        if (this._imageMenu == null) {
            var factory = AM.component.menu.MenuItemFactory;
            this._imageMenu = Ext.create('Ext.menu.Menu', {
                items:[
                    factory.rotate(),
                    factory.scale(),
                    factory.opacity(),
                    factory.width(),
                    factory.height(),
                    factory.zIndex(),
                    factory.delete()
                ]
            })
        }
        return this._imageMenu;
    },

    audioMenu:function () {
        if (this._audioMenu == null) {
            var factory = AM.component.menu.MenuItemFactory;
            this._audioMenu = Ext.create('Ext.menu.Menu', {
                items:[
                    factory.play(),
                    factory.pause(),
                    factory.rotate(),
                    factory.scale(),
                    factory.width(),
                    factory.src(),
                    factory.zIndex(),
                    factory.delete(),
                    factory.edit()
                ]
            })
        }

        return this._audioMenu;
    },


    videoMenu:function () {
        if (this._videoMenu == null) {
            var factory = AM.component.menu.MenuItemFactory;
            this._videoMenu = Ext.create('Ext.menu.Menu', {
                items:[
                    factory.rotate(),
                    factory.scale(),
                    factory.src(),
                    factory.zIndex(),
                    factory.delete()
                ]
            })
        }
        return this._videoMenu;
    },


    shapeMenu:function () {
        if (this._shapeMenu == null) {
            var factory = AM.component.menu.MenuItemFactory;
            this._shapeMenu = Ext.create('Ext.menu.Menu', {
                items:[
                    factory.rotate(),
                    factory.scale(),
                    factory.width(),
                    factory.height(),
                    factory.opacity(),
                    factory.zIndex(),
                    factory.delete()
                ]
            })
        }
        return this._shapeMenu;
    },


    tableMenu:function () {
        if (this._tableMenu == null) {
            var factory = AM.component.menu.MenuItemFactory;
            this._tableMenu = Ext.create('Ext.menu.Menu', {
                items:[
                    factory.rotate(),
                    factory.scale(),
                    factory.width(),
                    factory.height(),
                    factory.backgroundColor(),
                    factory.backgroundImage(),
                    factory.edit(),
                    factory.zIndex(),
                    factory.delete()
                ]
            })
        }
        return this._tableMenu;
    },


    pageMenu:function () {
        if (this._pageMenu == null) {
            var factory = AM.component.menu.MenuItemFactory;
            this._tableMenu = Ext.create('Ext.menu.Menu', {
                items:[
                    factory.backgroundColor(),
                    factory.backgroundImage(),
                    factory.anim(),
                    factory.cutOverAudio(),
                    factory.deletePage()
                ]
            })
        }
        return this._tableMenu;
    }



})